package com.bridgeintelligent.tag.webserver.security;

import com.bridgeintelligent.tag.constants.ExceptionCodes;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.springframework.stereotype.Component;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

@Component
public class AjaxFilterDefinition extends FilterDefinition {

    public AjaxFilterDefinition() {
        setName("tagAuthc");
        setFilter(new AjaxFilter());
    }

    public static class AjaxFilter extends FormAuthenticationFilter {

        @Override
        protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
            throw new AuthenticationException(ExceptionCodes.SECURITY_50003);
        }
    }
}
